
import {createRouter,createWebHashHistory, RouteRecordRaw} from "vue-router"
import Nprogress from 'nprogress'
const routes:Array<RouteRecordRaw> = []

const aboutRoute = {
    path:'/about',
    name:"about",
    component: ()=> import("@/views/about/index.vue")
} as RouteRecordRaw

const modules:Record<string,any> = import.meta.glob(["./modules/*.ts"],{ eager: true })

Object.keys(modules).forEach((key) => {
    const module = modules[key].default
    routes.push(module)
})
routes.push(aboutRoute)

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach(async (_to,_from,next) => {
    Nprogress.start()
    next()
})

router.afterEach((_to) => {
    Nprogress.done()
})


export default router